package com.huangyi;
public class Main {

    public static void main(String[] args) {

        //快乐数
        class Solution {
            public int bitSum(int n) {
                int sum = 0;
                while (n > 0) {
                    int t = n % 10;
                    sum += t * t;
                    n = n / 10;
                }
                return sum;
            }

            public boolean isHappy(int n) {
                int slow = n;
                int fast = n;
                while (true) {
                    slow = bitSum(slow);
                    fast = bitSum(bitSum(fast));
                    if (slow == fast) {
                        break;
                    }
                }
                if (slow == 1) {
                    return true;
                } else {
                    return false;
                }
            }
        }




        //盛水最多容器
        class Solution {
            public int maxArea(int[] height) {
                int left = 0, right = height.length - 1, ret = 0;
                while (left < right) {
                    int v = Math.min(height[left], height[right]) * (right - left);
                    ret = Math.max(ret, v);
                    if (height[left] < height[right]) left++;
                    else right--;
                }
                return ret;

            }
        }





    }

}